/*
* @author suhong
* @date 2022/5/27 22:00
* @file index.js
* @说明  后台管理相关接口函数
*/
//导入数据库
const exec=require('../../db/mysql_connect')
//首页最近发布文章的接口函数
exports.getLateNews=((req,res)=>{
    let sqlStr=`select blog_user.user_name,blog_user.user_icon,blog_article.article_id,blog_article.putout_time,blog_article.article_title from blog_article,blog_user where blog_article.user_id=blog_user.user_id ORDER BY putout_time  desc LIMIT 0,10`
    exec(sqlStr).then(value => {
        res.send(value)
    }).catch(reason => {
        res.send(reason)
    })
})
//首页作者发布量
exports.getNewsNumber=((req,res)=>{
    let sqlStr='select * from(select blog_user.user_name,blog_user.user_icon,count(blog_article.user_id) as sum from blog_article,blog_user where blog_article.user_id=blog_user.user_id  GROUP BY blog_article.user_id ) a ORDER BY  a.sum desc LIMIT 0,10'
   exec(sqlStr).then(value => {
       res.send(value)
   }).catch(reason => {
       res.send(reason)
   })
})